package rulemodel

type Rule struct {
	ID          int    `validate:"min=0"`                                                       // ID
	Name        string `validate:"required"`                                                    // 名字
	IP          string `validate:"omitempty,ip_addr"`                                           // IP地址
	Mask        string `validate:"omitempty,ip_addr"`                                           // 掩码
	StartPort   int    `db:"start_port" validate:"omitempty,gte=-1,lte=65535"`                  // 开始端口
	EndPort     int    `db:"end_port" validate:"omitempty,gte=-1,lte=65535,gtefield=StartPort"` // 结束端口
	UrlSuffix   string `db:"url_suffix" validate:"omitempty"`                                   // url后缀
	IsMIN       int    `db:"is_min" validate:"gte=0,lte=1,required"`                            // 是否MIN，不能加required???
	IsInner     int    `db:"is_inner" validate:"gte=0,lte=1,required"`                          //0 外网资源 1内网资源
	Signer      string `validate:"required"`                                                    // 创建者
	Description string `validate:"omitempty"`                                                   // 规则描述
}

type RuleInfo struct {
	ID   int    `validate:"required"`
	Name string `validate:"required"`
}

type RuleID struct {
	ID int `validate:"required"`
}

type UGroupID struct {
	ID int `validate:"required"`
}

type GetUGroupRule struct {
	PageSize int `validate:"required"` // 页尺寸
	PageNo   int `validate:"required"` // 页号
	UGroupID int `validate:"required"` //用户组ID
}

type GetUserRule struct {
	PageSize int `validate:"required"` // 页尺寸
	PageNo   int `validate:"required"` // 页号
	UserID   int `validate:"required"` // 用户ID
}

type RGroupRuleGet struct {
	PageSize int `validate:"required"` // 页尺寸
	PageNo   int `validate:"required"` // 页号
	RGroupID int `validate:"required"` // 用户ID
}

type GetAllRule struct {
	PageSize int `validate:"required"` // 页尺寸
	PageNo   int `validate:"required"` //  页号
}

type RuleIDList struct {
	IDs []int `validate:"gt=0,unique,required"`
}

type UGroupRuleIDList struct {
	IDs      []int `validate:"gt=0,unique,required"` // 规则ID
	UGroupID int   `validate:"required"`             // 用户组ID
}

type GrantUGroup struct {
	IDs      []int  `validate:"gt=0,unique,required"` // 规则ID
	UGroupID int    `validate:"required"`             // 用户组ID
	Signer   string `validate:"required"`             // 授予者名字
}

type DepriveUGroup struct {
	IDs      []int `validate:"required"` // 规则ID
	UGroupID int   `validate:"required"` // 用户组ID
}

type GrantUser struct {
	IDs    []int  `validate:"gt=0,unique,required"` // 规则ID
	UserID int    `validate:"required"`             // 用户ID
	Signer string `validate:"required"`             // 授予者名字
}

type DepriveUser struct {
	IDs    []int `validate:"gt=0,unique,required"` // 规则ID
	UserID int   `validate:"required"`             // 用户ID
}

type RevokedRule struct {
	RuleID    int `db:"r_id"`
	IsDeleted int
}
